package com.bkhc.product.repository;

import com.bkhc.product.entity.BrandGoodPrice;
import com.bkhc.product.entity.BrandGoods;
import com.bkhc.product.entity.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public interface BrandGoodsRepository extends JpaRepository<BrandGoods,String>, JpaSpecificationExecutor<BrandGoods> {


    List<BrandGoods> findByProductCodeAndBrandCode(String productCode,String brandCode);
    BrandGoods findByGoodsCodeAndBrandCode(String goodsCode,String brandCode);

    void deleteByBrandCode(String brandCode);
    @Modifying
    @Query("delete from BrandGoods p where p.brandCode=:brandCode and p.productCode=:productCode ")
    void deleteByBrandCodeAndProductCode(@Param("brandCode") String brandCode, @Param("productCode") String productCode);

    void deleteByProductCode(String productCode);


    List<BrandGoods> findByProductCodeIn(List<String> products);
}
